import java.util.ArrayList;

/**Class represents a Person.
 * 
 * @author Kurt Micheli
 * @author Gabriel Rauter
 * @author Max Mulatz
 */
abstract class Person {
	
	private String name = ""; // vorname
	private String surname = ""; // nachname
	private ArrayList<Message> messages= null;
	
	/**Creates a Person.
	 * 
	 * @param name name of a Person.
	 * @param surname surname of a Person.
	 */
	public Person(String name, String surname) {
		this.name = name;
		this.surname = surname;
		messages = new ArrayList<Message>();
	}
	
	/**Sends message to Person.
	 * 
	 * @param from from who?
	 * @param content Content of the message.
	 */
	public void SendMessage(String from, String content) {
		messages.add(new Message(from, content));
	}
	
	/**Returns the Name of a Person
	 *
	 * @return String Name of a Person
	 */
	public String getName() {
		return this.name;
	}
	
	/**Returns the Surname of a Person
	 *
	 * @return String Surname of a Person
	 */
	public String getSurName() {
		return this.surname;
	}
	
	/**Returns all messages form the Person
	 *
	 * @return String well formatted messages
	 */
	public String CheckMessages() {
		String temp ="";
		for(int i = 0;i < messages.size();i++) {
			if(i == messages.size()-1) {
				temp += messages.get(i).toString();
			}else {
				temp += messages.get(i).toString()+'\n';
			}
		}
		return temp;
	}
	
	/**Returns all information form the Person
	 *
	 * @return String Name Surname
	 */
	public String toString() {
		return this.getName()+" "+ this.getSurName();
	}
	
}
